<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数参数默认值</title>
</head>
<body>
    <script>
        //ES6 允许给函数参数赋值初始值  
        // function buildPhone(phoneNum, area="+86 "){
        //     return area + phoneNum;
        // }

        //调用函数创建手机号
        // let res = buildPhone('13569874125');
        // let res = buildPhone('13569874125', "+01 ");
        // console.log(res);
        
        //解构赋值
        // function connect(options){
        //     console.log(options.host)
        //     console.log(options.port)
        //     console.log(options.user)
        //     console.log(options.pass)
        // } 

        function connect({port, user, pass, host='127.0.0.1'}){
            console.log(host)
            console.log(port)
            console.log(user)
            console.log(pass)
        } 

        connect({
            // host: '192.168.3.5',
            port: 3306, //
            user: 'root',
            pass: 'root'
        })

        
    </script>
</body>
</html>